﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.Bll;
using Acms.WebControls;

public partial class Templates_Portal_Default : Acms.AcmsControls.TemplatePage
{
     protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind();
        }
    }

     //protected string GetFlash()
     //{
     //    return "http://" + HttpContext.Current.Request.Url.Host + ResolveUrl("~/Flash/ImageScroller.swf");
     //}

     protected string GetImgSrc()
     {
         var heroImage = AcmsContext.CurrentPost.FindPostControl("HeroImage");
         var host = HttpContext.Current.Request.Url.Host;
         if (heroImage != null)
         {
             var heroImageProperties = heroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             if (heroImageProperties != null)
             {
                 return "http://"+host+ResolveUrl(Acms.AcmsControls.RenderFile.GetUrl(heroImageProperties.ResourceId, null, null, this));
             }
         }
         return null;
     }


     public override void DataBind()
     {
         base.DataBind();
         var post = AcmsContext.CurrentPost;

         if (post != null)
         {
             //if (pnlItem != null)
             //{
             //    var HeroImage = post.FindPostControl("HeroImage");// as ImageContentControlDisplay;
             //    if (HeroImage != null)
             //    {
             //        var prop = HeroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             //        if (prop != null && prop.HasResource())
             //        {
             //            pnlItem.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
             //        }
             //    }
             //}

             //var HeroImage = post.FindPostControl("UAVStrip");// as ImageContentControlDisplay;
             //if (HeroImage != null)
             //{
             //    var prop = HeroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             //    if (prop != null && prop.HasResource())
             //    {
             //        pnlItem1.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
             //    }
             //}

             //HeroImage = post.FindPostControl("MineStrip");// as ImageContentControlDisplay;
             //if (HeroImage != null)
             //{
             //    var prop = HeroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             //    if (prop != null && prop.HasResource())
             //    {
             //        pnlItem2.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
             //    }
             //}

             //HeroImage = post.FindPostControl("CompositeStrip");// as ImageContentControlDisplay;
             //if (HeroImage != null)
             //{
             //    var prop = HeroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             //    if (prop != null && prop.HasResource())
             //    {
             //        pnlItem3.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
             //    }
             //}

             //HeroImage = post.FindPostControl("NewsStrip");// as ImageContentControlDisplay;
             //if (HeroImage != null)
             //{
             //    var prop = HeroImage.GetProperties<Acms.AcmsControls.ImageContentControlProperties>();
             //    if (prop != null && prop.HasResource())
             //    {
             //        pnlItem4.BackImageUrl = Acms.AcmsControls.RenderFile.GetUrl(prop.ResourceId, this.Page);
             //    }
             //}
         }
     }
}